|
![](/i/fill.gif) |
High everybody!
As a development of my "From Pole to Pole" animations, I began with
customizable general inter-continental flight/orbital
animations, where not only the current geographical coordinates, the
total distance travelled and the time elapsed since start
are displayed, but also the six or eight nearest of all capitals of the
world.
It's obvious that I have to sort the distances of the capitals once
again in the calculation of each frame, so I looked up the
Quicksort algorithm in my C tutorial. But there, Quicksort is
implemented as a recursive function (which returns no value),
now my question: is #macro equivalent to "non-returning" functions? Or
do I have to do it all as a series of nested loops?
Here is what I programmed up to now:
#declare buf;
#declare left=0;
#declare right=dimension_size(Dists, 1);
#declare m=Dists[(left+right)/2][1];
#declare i=left;
#declare j=right;
#while (left<j | i<right)
#if (links<j) // uncompleted!
#while(i>=j)
#while (Dists[i][1]<m) #declare i=i+1; #end
#while (Dists[j][1]>m) #declare j=j-1; #end
#if (i>=j)
#declare buf=Dists[i][1];
#declare Dists[i][1]=Dists[j][1];
#declare Dists[j][1]=buf;
#declare i=i+1;
#declare j=j-1;
#end
#end
#end
See you in Khyberspace!
Yadgar
Now playing: Curious Electric (Jon and Vangelis)
Post a reply to this message
|
![](/i/fill.gif) |